def factorial(x="None"):


    if (x=="None"):
        x = input("Enter a non-negative integer: ")

    # Want to make sure that the user did not supply rubbish input
    if (x < 0 ):
        print "Cannot compute factorial of negative integers, program will exit"
        return


    # What if the user does not supply an integer?

    # one solution:
    #x = int(x)

    # another solution, using type
    # could use type, but isinstance is better
    #if not "int" in str(type(x)):
    #if not isinstance(x,int):
        #print "Please enter an integer number, program will exit"
        #return

    # often better to assume that x has correct type and handle any errors that result

    # Compute the factorial
    prod = 1

    #for i in range(1,x+1):
        #prod = prod * i

     # Special case for x = 0 (0! = 1)
    if not x==0:

        for i in range(x):
            prod  = prod * (i+1)

   
    print str(x) + "! = " + str(prod)

def recursiveFactorial(x):

    if x <= 1:   # base case
        return 1
    else:
        return x * recursiveFactorial(x-1)

    # The 'loop' is in the recursion

# There is not practical difference in computing time for the two methods. The recursive function has a limit of x=993, then python will issue an error saying "maximum recursion level reached".






